﻿using System.Data.Entity;
using System.Data.Entity.Infrastructure;
using System.Data.Entity.ModelConfiguration;
using System.Data.Entity.ModelConfiguration.Conventions;

namespace OpenScrum.db
{
    public class OpenScrumDataContext : DbContext
    {
        public DbSet<Project> Projects { get; set; }
        public DbSet<Swimlane> Swimlanes { get; set; }
        public DbSet<TeamMember> TeamMembers { get; set; }
        public DbSet<BacklogItem> BacklogItems { get; set; }
        public DbSet<BacklogItemTest> BacklogItemTests { get; set; }
        public DbSet<User> Users { get; set; }
        public DbSet<Role> Roles { get; set; }

        protected override void OnModelCreating(DbModelBuilder modelBuilder)
        {
            // removes the EdmMetadata table EF creates since it is not needed when using migrations
            modelBuilder.Conventions.Remove<IncludeMetadataConvention>();
            modelBuilder.Conventions.Remove<PluralizingTableNameConvention>();
            modelBuilder.Configurations.Add(new ProjectConfiguration());
            modelBuilder.Configurations.Add(new BacklogItemConfiguration());
            modelBuilder.Configurations.Add(new BacklogItemTestConfiguration());
        }
    }
}
